/* 
 * File:   XUDPScaner.h
 * Author: minaev
 *
 * Created on 5 Ноябрь 2013 г., 12:24
 */

#ifndef XUDPSCANER_H
#define	XUDPSCANER_H

#include <pthread.h>

#include "XUDPListener.h"
#include "XUDPServ.h"
#include "XUDPShareMem.h"
#include "XbeeContainer.h"

class XUDPScaner:public XUDPListener {
public:
    XUDPScaner(XUDPServ* udpServ, XbeeContainer* xcont);
    virtual ~XUDPScaner();
    void startThread();
    
    virtual void readUDP();
    static uint16_t getLengthInPack(const char* msg);
    void statusHandler(uint16_t numXbee);
private:
    static void* threadScanerFunc(void* obj);
    int proccessBuffer(char* msg, int lenmsg,uint32_t ip);
    
    XUDPServ* udpServ;
    XUDPShareMem* updShmem;
    XbeeContainer* xcont;
    int workThreadScan;
    pthread_t scanUDPThread;
    pthread_mutex_t pauseMutex;
    pthread_cond_t  pauseCond;
    
};

#endif	/* XUDPSCANER_H */

